package com.twu.biblioteca.Options;

import com.twu.biblioteca.DataBase.Item;
import com.twu.biblioteca.DataBase.ItemType;
import com.twu.biblioteca.DataBase.ListOfItems;

import java.util.Scanner;

public class CheckOutOption extends Option{
    private Scanner scanner;
    public CheckOutOption() {
        name = "Check-Out";
        scanner = new Scanner(System.in);

    }

    @Override
    public void execute(ListOfItems listOfItems) {
        System.out.println("Book or Movie?");
        ItemType itemType = ItemType.valueOf(scanner.nextLine());

        System.out.println("Please type in Serial Number:");

        String serialNumberString = scanner.nextLine();
        int serialNumber = Integer.parseInt(serialNumberString);
        Item item = listOfItems.getBySerialNumber(serialNumber, itemType);
            if(item != null){
                item.checkOut();
            }
    }
}
